package com.mate.cloud.lottery.service.stock;

import com.mate.cloud.lottery.constants.LotteryConstants;
import com.mate.cloud.lottery.service.AsyncLotteryRecordTask;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * @description:    java类作用描述
 * @author:         MI
 * @email:          448341911@qq.com
 * @createTime:     2025/1/24 13:10
 * @updateUser:     MI
 * @updateTime:     2025/1/24 13:10
 * @updateRemark:   修改内容
 * @version:        v1.0
 */
@Service
public class NoneStockRewardProcessor extends AbstractRewardProcessor {

    @Resource
    AsyncLotteryRecordTask asyncLotteryRecordTask;

    @Override
    protected void afterProcessor(RewardContext context) {
        asyncLotteryRecordTask.saveLotteryRecore(context.getAccountIp(), context.getLotteryItem(), context.getPrizeName());
    }

    @Override
    protected int getAwardType() {
        return LotteryConstants.PrizeTypeEnum.THANK.getValue();
    }

    @Override
    protected void processor(RewardContext context) {
        List<Object> propertys = Arrays.asList("id", "prizeName");
        List<Object> prizes = redisTemplate.opsForHash().multiGet(context.getKey(), propertys);
        context.setPrizeId(Integer.parseInt(prizes.get(0).toString()));
        context.setPrizeName(prizes.get(1).toString());

    }
}
